<?php
class UserModel extends AdvModel
{
	// 自动填充规则
	var $_auto = array(
		array("password","md5",1,"function"),
		array("regtime","time",1,"function"),
		array("image","",1,"string"),
		array("score","0",1,"string"),
		array("status","0",1,"string"),
	);

	// 自动校验规则
	var $_validate = array(
		array('username','require','用户名不能为空',0,'',3),
		array('password','require','密码不能为空',0,'',1),
		array('email','require','邮箱不能为空',0,'',3),
		array('email','email','邮箱格式错误',0,'',3),
		array('nickname','require','昵称不能为空',0,'',3),
		array('username','isPassword','帐号格式错误（6-12的字母、数字、下划线的组合）',0,'callback',3),
	//	array('nickname','/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]{1,12}$/u','昵称含有非法字符或者超过12位',0,'regex',3),
		//array('password','isPassword','密码长度不对(6-12)', 0 ,'callback',1),  //  自定义函数验证密码格
		array('repassword','password',' 密码不一致 ', 0 , 'confirm'),  //  验证确认密码是否和密码一致
		array("email","require","该邮箱已经被使用",0,"unique",3),
		array("username","require","帐号已经被使用",0,"unique")
	);

	protected function isPassword($pwd)
	{
		if(preg_match("/^[0-9a-zA-Z_]{6,16}$/",$pwd)) return true;
		return false;
	}
}
?>